from manim import *

class EuclideanAxioms(Scene):
    def construct(self):
        # 设置全局字体大小
        text_scale = 0.6
        
        # 设置场景的尺寸
        self.camera.frame_width = 16
        self.camera.frame_height = 9
        
        # 第一公理：从一点到另一点可以画一条直线
        first_axiom_text = Text("第一公理: 从一点到另一点可以画一条直线").scale(text_scale).to_edge(UP + LEFT)
        self.play(Write(first_axiom_text))

        point_a = Dot(LEFT * 2 + DOWN)
        point_b = Dot(RIGHT * 2 + DOWN)
        line_ab = Line(point_a.get_center(), point_b.get_center())
        self.play(Create(point_a), Create(point_b))
        self.play(Create(line_ab))
        self.wait(1)

        # 第二公理：一条直线可以无限延长
        second_axiom_text = Text("第二公理: 一条直线可以无限延长").scale(text_scale).next_to(first_axiom_text, DOWN, aligned_edge=LEFT)
        self.play(Write(second_axiom_text))

        line = Line(LEFT * 2, RIGHT * 2).shift(DOWN * 2)
        extended_line = Line(LEFT * 5, RIGHT * 5).shift(DOWN * 2)
        self.play(Create(line))
        self.play(Transform(line, extended_line))
        self.wait(1)

        # 第三公理：以任意一点为圆心，任意长度为半径，可以画一个圆
        third_axiom_text = Text("第三公理: 以任意一点为圆心，任意长度为半径，可以画一个圆").scale(text_scale).next_to(second_axiom_text, DOWN, aligned_edge=LEFT)
        self.play(Write(third_axiom_text))

        center = Dot(DOWN * 2)
        circle = Circle(radius=2).move_to(center.get_center())
        self.play(Create(center))
        self.play(Create(circle))
        self.wait(1)

        # 第四公理：所有直角都相等
        fourth_axiom_text = Text("第四公理: 所有直角都相等").scale(text_scale).next_to(third_axiom_text, DOWN, aligned_edge=LEFT)
        self.play(Write(fourth_axiom_text))

        right_angle_1 = RightAngle(Line(LEFT, RIGHT), Line(DOWN, UP), length=1, color=YELLOW).shift(DOWN * 2 + LEFT * 3)
        right_angle_2 = RightAngle(Line(RIGHT, LEFT), Line(DOWN, UP), length=1, color=YELLOW).shift(DOWN * 2 + RIGHT * 3)
        self.play(Create(right_angle_1))
        self.play(Create(right_angle_2))
        self.wait(1)

        # 第五公理：通过平面上一点，可以作且只能作一条直线与已知直线平行
        fifth_axiom_text = Text("第五公理: 通过平面上一点，可以作且只能作一条直线与已知直线平行").scale(text_scale).next_to(fourth_axiom_text, DOWN, aligned_edge=LEFT)
        self.play(Write(fifth_axiom_text))

        line = Line(LEFT * 3, RIGHT * 3, color=BLUE).shift(DOWN * 2)
        point = Dot(UP * 2 + DOWN * 2, color=BLUE)
        parallel_line = Line(point.get_center() + LEFT * 3, point.get_center() + RIGHT * 3, color=GREEN)
        self.play(Create(line))
        self.play(Create(point))
        self.play(Create(parallel_line))
        self.wait(1)